<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	 function myfn(x){
		 switch(x){
		 case 1:// 添加
		 	var li = document.createElement("li");
		 	li.innerText = i1.value;
		 	myul.appendChild(li);
		 	break;
		 case 2:// 插入
			 var li = document.createElement("li");
			 li.innerText = i1.value;
			 myul.insertBefore(li,sh);
		 	break;
		 case 3://删除
		     myul.removeChild(sh);
		 	break;
		 }	 
	 }
</script>
</head>
<body>
	<input type="text" id="i1">
	<input type="button" value=添加 onclick="myfn(1)">
	<input type="button" value=插入 onclick="myfn(2)">
	<input type="button" value=删除 onclick="myfn(3)">
<ul id="myul">
<li>北京</li>
<li id="sh">上海</li>
<li>广州</li>	
</ul>
</body>
</html>